package com.example.demo.common;

import java.util.Date;

public interface BaseEntity {

    String getUuid();
    void setUuid(String uuid);

    Date getCreatedAt();
    void setCreatedAt(Date createdAt);

    Date getUpdatedAt();
    void setUpdatedAt(Date updatedAt);

    String getCreatedBy();
    void setCreatedBy(String createdBy);

    String getUpdatedBy();
    void setUpdatedBy(String updatedBy);


    void BaseEntityImp();

    default void init(String createdBy, Date updatedBy) {
        this.BaseEntityImp();
        this.setCreatedBy(createdBy);
        this.setCreatedAt(updatedBy);
    }
    default void init() {
        this.BaseEntityImp();
        this.setCreatedBy(this.getCreatedBy());
        this.setCreatedAt(new Date());
    }

    default void initUpdate(String updatedBy) {
        this.setUpdatedBy(updatedBy.isEmpty()?"system": updatedBy);
        this.setUpdatedAt(new Date());
    }

    default void initUpdate() {
//        this.BaseEntityImp();
        this.setUpdatedBy(this.getUpdatedBy());
        this.setUpdatedAt(new Date());
    }
}
